package com.ruoyi.web.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.domain.MyMessage;
import com.ruoyi.web.mapper.MyMessageMapper;
import com.ruoyi.web.utils.UserMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;;
import com.ruoyi.system.service.IMyMessageService;

/**
 * messageService业务层处理
 *
 * @author ruoyi
 * @date 2024-04-24
 */
@Service
public class MyMessageServiceImpl implements IMyMessageService {
    @Autowired
    private MyMessageMapper myMessageMapper;
    @Autowired
    private ISysUserService userService;

    /**
     * 查询message
     *
     * @param id message主键
     * @return message
     */
    @Override
    public MyMessage selectMyMessageById(Long id) {
        return myMessageMapper.selectMyMessageById(id);
    }

    /**
     * 查询message列表
     *
     * @param myMessage message
     * @return message
     */
    @Override
    public List<MyMessage> selectMyMessageList(MyMessage myMessage) {
        if (UserMsgUtil.getUserId() != null) {
            // 当前用户存在
            // 将userId赋值到查询条件中
            myMessage.setUserId(UserMsgUtil.getUserId());
        }

        return myMessageMapper.selectMyMessageList(myMessage);
    }

    /**
     * 新增message
     *
     * @param myMessage message
     * @return 结果
     */
    @Override
    public int insertMyMessage(MyMessage myMessage) {
        return myMessageMapper.insertMyMessage(myMessage);
    }

    /**
     * 修改message
     *
     * @param myMessage message
     * @return 结果
     */
    @Override
    public int updateMyMessage(MyMessage myMessage) {
        return myMessageMapper.updateMyMessage(myMessage);
    }

    /**
     * 批量删除message
     *
     * @param ids 需要删除的message主键
     * @return 结果
     */
    @Override
    public int deleteMyMessageByIds(Long[] ids) {
        return myMessageMapper.deleteMyMessageByIds(ids);
    }

    /**
     * 删除message信息
     *
     * @param id message主键
     * @return 结果
     */
    @Override
    public int deleteMyMessageById(Long id) {
        return myMessageMapper.deleteMyMessageById(id);
    }
}
